﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Straight_Line_Depreciation
{
    public partial class SNL : Form
    {
        public SNL()
        {
            InitializeComponent();
        }

        private void SNL_Load(object sender, EventArgs e)
        {

        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            //Clear all text boxes and set focus on Cost text box
            txtCost.Clear();
            txtSalvage.Clear();
            txtYears.Clear();
            txtDepreciation.Clear();
            txtCost.Focus();
        }

        private void btnCalculate_Click(object sender, EventArgs e)
        {
            //Calculate Straight Line depreciation
            //Declaration Section
            decimal decCost = 0m; //Cost
            decimal decSalvage = 0m; //Salvage
            byte bytYears = 1; //Life
            decimal decDepreciation = 0m; //Depreciation
            //Assignment section
            decCost = Convert.ToDecimal(txtCost.Text);
            decSalvage = Convert.ToDecimal(txtSalvage.Text);
            bytYears = Convert.ToByte(txtYears.Text);
            //Calculation section
            decDepreciation = (decCost - decSalvage) / bytYears;
            //Display section
            txtDepreciation.Text = String.Format("{0:C}", decDepreciation);
        }

        private void btnQuit_Click(object sender, EventArgs e)
        {
            // Terminate application
            Application.Exit();
        }
    }
}
